package com.app.mapper;

import com.app.model.IntegralOrderModel;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.yulichang.base.MPJBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 16693103420
 * @since 2024-02-01
 */
@Mapper
public interface IntegralOrderMapper extends MPJBaseMapper<IntegralOrderModel> {

    Double getMonthlyConsumption(@Param("userId")Integer userId);

    Double getMonthlyPointsConsumption(@Param("userId")Integer userId);

    BigDecimal queryUserStatusPoints(@Param("startTime") String startTime, @Param("endTime")  String endTime);
    BigDecimal queryPointsExchangeAmount(@Param("startTime") String startTime, @Param("endTime")  String endTime);

    BigDecimal  querySumIntegralValues(@Param("startTime") String startTime, @Param("endTime")  String endTime);


    @Select("select o.*,g.business_id,g.business_userid\n" +
            "from tb_integral_order o\n" +
            "left join tb_goods g on o.goods_id = g.id\n" +
            "where o.code = #{code}  and g.apply_type=2 ")
    IntegralOrderModel queryIntegralOrderByCode(String code);
}
